<?php
namespace common\services\common\SMS;
use common\models\Functions;
use linslin\yii2\curl\Curl;
use yii\base\Exception;

/**
 * 腾讯云 短信接口
 */
class SmsTX
{
    /**私有静态参数**/
    private $appId;                                 //短信应用列表里面的 APP ID
    private $appkey;                                //短信应用列表里面的 APP KEY

    private $secretId ;                             //腾讯云账户的secretID
    private $secretKey;                             //腾讯云账户的secretKey

    private $sign;                                  //签名

    private $api;

    public function __construct() {
    }
    const TX_LOGIN_TPL = 573714;
    const TX_CHECK_OLD_PHONE_TPL = 573717;
    const TX_CHECK_NEW_PHONE_TPL = 573719;
    const TX_REGISTER_TPL = 579249;
    const TX_FORGET_TPL = 579254;

    public function send($to = '', $params = [], $templateId = '') {
        try {

            $ssender = new SmsSingleSender($this->appId, $this->appkey);

            $result = $ssender->sendWithParam('86', $to, $templateId, $params, $this->sign, "", "");

            $rsp = json_decode($result, true);

            return $rsp;
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }
}